﻿using System.Linq;
using netCoreStudy.Dto.User;
using netCoreStudy.Entities;
using netCoreStudy.Entities.Base;

namespace netCoreStudy.Profile
{
	public class RoleProfile : BaseProfile<Role, RoleDto, AddRoleDto, UpdateRoleDto>
	{
		public RoleProfile()
		{
			Entity2Dto
				.ForMember(d => d.Menus, o => o.MapFrom(s => s.RoleMenus));
			Update2Entity.ForMember(d => d.RoleMenus,
				o => o.MapFrom(s => s.MenuIds.Select(x => new RoleMenu() {MenuId = x})));
		}
	}
}